package fule.com.appbarlayoutdemo.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.List;

/**
 * 作者： njb
 * 时间： 2018/12/26 20:50
 * 描述：
 * 来源：
 */
public class MyFragmentPagerAdapter extends FragmentPagerAdapter {
    private List<Fragment> listfragment; //创建一个List<Fragment>

    public MyFragmentPagerAdapter(FragmentManager fm, List<Fragment> list) {
        super(fm);
        this.listfragment=list;
    }

    @Override
    public Fragment getItem(int position) {
        switch (position) {
            case 0:
                return listfragment.get(position);
            case 1:
                return listfragment.get(position);
            case 2:
                return listfragment.get(position);
            case 3:
                return listfragment.get(position);
            case 4:
                return listfragment.get(position);
        }
        return listfragment.get(position);
    }

    @Override
    public int getCount() {
        return listfragment.size(); //总共有多少个fragment
    }
}
